/**
 * Copyright (c) 华南农业大学信息学院蔡超敏2015版权所有
 * 
 * 文件创建时间：2015年7月2日
 */
package org.scauinfo.fpos.service.impl;

import java.io.Serializable;
import java.util.List;

import org.scauinfo.fpos.dao.impl.UserpermissionDao;
import org.scauinfo.fpos.service.UserpermissionService;
import org.scauinfo.fpos.vo.Userpermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 蔡超敏
 * 
 */
@Service
public class UserpermissionServiceImpl implements UserpermissionService {
	@Autowired
	private UserpermissionDao userpermissionDao;

	@Override
	public void saveUserpermission(Userpermission userpermission) {
		userpermissionDao.save(userpermission);
	}

	@Override
	public void updateUserpermission(Userpermission userpermission) {
		userpermissionDao.update(userpermission);
	}

	@Override
	public void deleteUserpermission(int id) {
		Userpermission userpermission = userpermissionDao.get(id);
		userpermissionDao.delete(userpermission);
	}

	@Override
	public List<Userpermission> findAllUserpermission(int page, int rows,
			String sort, String order) {
		return userpermissionDao.findAll(page, rows, sort, order);
	}

	@Override
	public int getTotal() {
		return userpermissionDao.countAll();
	}

	@Override
	public boolean isExist(String userpermissionId) {
		boolean flag = false;
		String hql = "from Userpermission as p where p.userpermissionId="
				+ userpermissionId;
		if (userpermissionDao.find(hql).size() > 0) {
			flag = true;
		}
		return flag;
	}

	@Override
	public List<Userpermission> findAllUserpermission() {
		return userpermissionDao.findAll();
	}

	@Override
	public Userpermission get(Serializable id) {
		return userpermissionDao.get(id);
	}

}
